import java.util.*;

public class DoubleRoshambo {
    public int maxScore(String[] A, String[] E) {
        boolean[] usedA = new boolean[A.length];
        boolean[] usedE = new boolean[E.length];
        int finalScore = 0;
        for (int i = 0; i < A.length; ++i) {
            for (int j = 0; j < E.length; ++j) {
                if (!(usedA[i] || usedE[j])) {
                    if (win(A[i].charAt(0), E[j].charAt(0)) &&
                            win(A[i].charAt(1), E[j].charAt(1))) {
                        usedA[i] = true;
                        usedE[j] = true;
                        finalScore += 2;
                    }
                }
            }
        }
        for (int i = 0; i < A.length; ++i) {
            for (int j = 0; j < E.length; ++j) {
                if (!(usedA[i] || usedE[j])) {
                    if (win(A[i].charAt(1), E[j].charAt(1)) &&
                            (A[i].charAt(0) == E[j].charAt(0))) {
                        usedA[i] = true;
                        usedE[j] = true;
                        ++finalScore;
                    }
                }
            }
        }
        return finalScore;
    }

    static boolean win(char first, char second) {
        return (first == 'R' && second == 'S') ||
                (first == 'S' && second == 'P') ||
                (first == 'P' && second == 'R');
    }
}
